import requests
import xmltodict
import time

# 滚轮，需要增加验证范围在list后添加0就可以了
start = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

# 滚轮调用的值，和滚轮同理需要添加调用值，在尾部添加自己的需要即可
key = [
        'a',
        'b',
        'c',
        'd',
        'e',
        'f',
        'g',
        'h',
        'i',
        'j',
        'k',
        'l',
        'm',
        'n',
        'o',
        'p',
        'q',
        'r',
        's',
        't',
        'u',
        'v',
        'w',
        'x',
        'y',
        'z',
    ]
keyNum = len(key) - 1

# 滚动一位
def startNext():
    global start
    for item in range(len(start)):
        key = len(start) - item - 1
        if start[key] == keyNum:
            start[key] = 0
        else:
            start[key] += 1
            break

# 获取域名
def getDomainName(type = 'com'):
    domainName = ''
    for i in range(len(start)):
        domainName += key[start[i]]
    return domainName + '.' + type

# 域名验证
def testDomainName(domainName):
    domainName = getDomainName()
    response = requests.post('http://panda.www.net.cn/cgi-bin/check.cgi?area_domain=' + domainName)
    if (response.text.find('<!DOCTYPE') == -1):
        return xmltodict.parse(response.text)
    else:
        time.sleep(.5)
        return testDomainName(domainName)

# 批量验证
def batchValidation():
    while True:
        time.sleep(.3)
        file = open('./pass.txt', 'a')
        if start[0] >= keyNum:
            print('已结束')
            break
        else:
            # 后缀控制有需要可以自主添加，例：.vip、.test.vip
            suffix = [
                'com',
                'cn'
            ]
            for item in suffix:
                domainName = getDomainName(item)
                result = testDomainName(domainName)
                print('标识：[' + ','.join(map(lambda x: str(x), start)) + ']，' + '域名：' + domainName, '结果：' + ('不可注册' if result["property"]["original"].find('210') == -1 else '可注册'))	
                file.write(domainName + '\n')
        file.close()
        startNext()

batchValidation()